
#ifndef _TEST_MEMCACHED_H_
#define _TEST_MEMCACHED_H_

#include <skyroad/memcache/memcache.hpp>

void test_memcached()
{
    memcache_singleton * memcached = memcache_singleton::get_instance();

    memcached->add_server("192.168.1.90:1088");
    memcached->add_server("192.168.1.90:1089");

    system("pause");

    for ( ; ; )
    {
        std::vector<std::string> mem_svrs;

        memcached->get_server_list(mem_svrs);

        if (mem_svrs.size() >  0)
        {
            for ( int i = 0 ; i < mem_svrs.size(); i++ )
            {
                std::cout << "server : " << mem_svrs[i].c_str() << std::endl;
            }

        }
        system("pause");
    }

    char * pp = "aaaaaaaaaaaaaaaaaaaa";
    memcached->set_item("a1",pp,strlen(pp),200);
    memcached->set_item("a2",pp,strlen(pp),200);
    memcached->set_item("a3",pp,strlen(pp),200);
    memcached->set_item("a4",pp,strlen(pp),200);
    memcached->set_item("a5",pp,strlen(pp),200);
    memcached->set_item("a6",pp,strlen(pp),200);
    memcached->set_item("a7",pp,strlen(pp),200);
    memcached->set_item("a8",pp,strlen(pp),200);
    memcached->set_item("a9",pp,strlen(pp),200);
    memcached->set_item("a10",pp,strlen(pp),200);
    memcached->set_item("a11",pp,strlen(pp),200);
    memcached->set_item("a12",pp,strlen(pp),200);


    char item[1024]= {0};
    memcached->get_item("a1",item,1024);
    std::cout << item << std::endl;
    system("pause");


    for (int i = 1 ; i < 10 ; i++)
    {
        std::string key = "a";
        key.append(boost::lexical_cast<std::string>(i));
        char t1[1024]= {0};
        memcached->get_item(key ,t1,1024);
        std::cout <<key.c_str()<<" ----> " << t1 << std::endl;

    }


    system("pause");
}

#endif
